package com.ktjy.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktjy.mapper.SysUserMapper;
import com.ktjy.pojo.SysRole;
import com.ktjy.pojo.SysUser;
import com.ktjy.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 实现登录方法
     * @param realName
     * @param password
     * @return
     */
    @Override
    public SysUser login(String realName, String password) {
        return sysUserMapper.login(realName, password);
    }

    /**
     * 实现查询用户列表
     *
     * @param queryRealName
     * @param queryRoleId
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @Override
    public List<SysUser> getUserList(String queryRealName, Integer queryRoleId, Integer pageIndex, int pageSize) {
        return sysUserMapper.getUserList(queryRealName, queryRoleId, pageSize, pageIndex);
    }

    /**
     * 实现查询用户总数
     *
     * @param queryRealName
     * @param queryRoleId
     * @return
     */

    @Override
    public int getUserCount(String queryRealName, Integer queryRoleId) {
        return sysUserMapper.getUserCount(queryRealName, queryRoleId);
    }

    /**
     * 实现添加用户
     *
     * @param sysUser
     * @return
     */
    @Override
    public boolean add(SysUser sysUser) {
        return sysUserMapper.add(sysUser);
    }

    /**
     * 实现根据id查询用户
     *
     * @param id
     * @return
     */
    @Override
    public SysUser getUserById(Integer id) {
        return sysUserMapper.getUserById(id);
    }

    /**
     * 实现根据账号和角色id查询用户是否存在
     *
     * @param account
     * @param roleId
     * @return
     */
    @Override
    public Integer getUserExist(String account, Long roleId) {
        return sysUserMapper.getUserExist(account, roleId);
    }
}



